package com.dingxiaopang.controller;

import com.alibaba.fastjson.JSON;
import com.dingxiaopang.domain.Product;
import com.dingxiaopang.service.ProductService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/product")
@Slf4j
public class ProductController {

    @Autowired
    private ProductService productService;

    @GetMapping("/{id}")
    public Product findById(@PathVariable Integer id){
        log.info("接下来对{}号商品进行查询",id);
        Product product = productService.findById(id);
        log.info("查询信息商品成功,内容为{}", JSON.toJSONString(product));
        return product;
    }
}
